import Cookies from 'js-cookie'
import axios from 'axios';
import router, { resetRouter } from '@/router'

const state = {
  role: Cookies.get('appId'), //1医生,2患者
  token: '',
  goodsMsg: Cookies.get('goodsMsg'),
  agreementState:false
}

const mutations = {
  SET_ROLE: (state, role) => {
    state.role = role
  },
  SET_GOODSLIST: (state, goodsMsg) => {
    state.goodsMsg = JSON.stringify(goodsMsg)
    Cookies.set('goodsMsg', JSON.stringify(goodsMsg))
  },
  SET_AGREEMENT:(state,val)=> {
    state.agreementState = val
  }
}

const actions = {
  setRole ({ commit }, role) {
    commit('SET_ROLE', role)
  },
  setGoodsList ({ commit }, goodsMsg) {
    commit('SET_GOODSLIST', goodsMsg)
  },
  setAgreement({commit},val){
    commit('SET_AGREEMENT', val)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

